/*
 * http://love.hackerzhou.me
 */

// variables
var $win = $(window);
var clientWidth = $win.width();
var clientHeight = $win.height();

$(window).resize(function() {
    var newWidth = $win.width();
    var newHeight = $win.height();
    if (newWidth != clientWidth && newHeight != clientHeight) {
        location.replace(location);
    }
});

(function($) {
	$.fn.typewriter = function() {
		this.each(function() {
			var $ele = $(this), str = $ele.html(), progress = 0;
			$ele.html('');
			var timer = setInterval(function() {
				var current = str.substr(progress, 1);
				if (current == '<') {
					progress = str.indexOf('>', progress) + 1;
				} else {
					progress++;
				}
				$ele.html(str.substring(0, progress) + (progress & 1 ? '_' : ''));
				if (progress >= str.length) {
					clearInterval(timer);
				}
			}, 75);
		});
		return this;
	};
})(jQuery);

function timeElapse(date){
	window.setTimeout("timeElapse()", 1000);
	together = new Date("6/29/2019 20:24:23");//相识的日期
	today = new Date();
	timeold = (today.getTime() - together.getTime());
	sectimeold = timeold / 1000
	secondsold = Math.floor(sectimeold);
	msPerDay = 24 * 60 * 60 * 1000
	e_daysold = timeold / msPerDay
	daysold = Math.floor(e_daysold);
	e_hrsold = (e_daysold - daysold) * 24;
	hrsold = Math.floor(e_hrsold);
	e_minsold = (e_hrsold - hrsold) * 60;
	minsold = Math.floor((e_hrsold - hrsold) * 60);
	seconds = Math.floor((e_minsold - minsold) * 60);
	var result = "第 <span class=\"digit\">" + daysold + "</span> 天 <span class=\"digit\">" + hrsold + "</span> 小時 <span class=\"digit\">" + minsold + "</span> 分鐘 <span class=\"digit\">" + seconds + "</span> 秒"; 
	$("#clock").html(result);
}
